package net.aspw.client.features.module.impl.exploit

import net.aspw.client.event.EventTarget
import net.aspw.client.event.UpdateEvent
import net.aspw.client.features.module.Module
import net.aspw.client.features.module.ModuleCategory
import net.aspw.client.features.module.ModuleInfo
import net.minecraft.client.gui.GuiGameOver

@ModuleInfo(name = "GhostMode", spacedName = "Ghost Mode", category = ModuleCategory.EXPLOIT)
class GhostMode : Module() {

    private var isGhost = false

    @EventTarget
    fun onUpdate(event: UpdateEvent) {
        if (mc.currentScreen is GuiGameOver) {
            mc.displayGuiScreen(null)
            mc.thePlayer.isDead = false
            mc.thePlayer.health = 20F
            mc.thePlayer.setPositionAndUpdate(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ)
            isGhost = true
            chat("You are now a ghost mode!")
        }
    }

    override fun onDisable() {
        if (isGhost) {
            mc.thePlayer.respawnPlayer()
            isGhost = false
        }
    }
}